/**
 * order.js-
 */
import request from '../request'
class order {
  constructor() {
    this._defaultHeader = {
      'data-tupe': 'application/json'
    }
    this._request = new request
    this._request.setErrorHandler(this.errorHander)
  }

  /**
   * 统一的异常处理方法
   */
  errorHander(res) {
    console.error(res)
  }

  /**
   * 匹配站点
   */
  matchingSites(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/matching-sites', data).then(res => res.data)
  }

  /**
   * 下单接口
   */
  placeOrder(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/place-order', data).then(res => res.data)
  }

  /**
   * 查询订单
   */
  selectOrder(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/select-order', data).then(res => res.data)
  }


    /**
   * 查询所有任务
   */
  getSendOrder(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/order/get-order-list?page='+data.page+"&size="+data.size, data).then(res => res.data)
  }

  getPayPageInfo(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/order/get-pay-page-info', data).then(res => res.data)
  }

  getOrderDetail(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/order/get-orders-detail', data).then(res => res.data)
  }

  /**
   * 查询进行中的任务
   */
  getReceiveOrder(data) {
    const app = getApp()
    return this._request.getRequest(app.globalData._baseUrl + 'sys/order/get-receive-orders', data).then(res => res.data)
  }

  updateStatus(data) {
    const app = getApp()
    return this._request.postRequest(app.globalData._baseUrl + 'sys/order/update-status', data).then(res => res.data)
  }
}
export default order